package ftl.games.piratas;

import java.util.Random;

import org.anddev.andengine.entity.modifier.PathModifier.Path;
import org.anddev.andengine.util.ArrayUtils;
import org.anddev.andengine.util.MathUtils;

public class Recorrido {

	private Path path;
	private int esquinaRandom = 0;
	
	public Recorrido (Path pPath )
	{
		this.path = pPath;
		
		
	}

	public Path generarPathDesdeEsquina( int pIndex )
	{
		Path pAux;
		int iTamanio = this.path.getSize();
		
		if (pIndex == 0)
			pAux = this.path;
		else
		{
			pAux = new Path(iTamanio+1);
			int pSdaVuelta = iTamanio - pIndex;
			
			for (int i = pIndex; i < iTamanio; i++ )
			{
				pAux.to(this.path.getCoordinatesX()[i], this.path.getCoordinatesY()[i]);
			}
			
			for( int i = 0; i <= pIndex; i++)
			{
				pAux.to(this.path.getCoordinatesX()[i], this.path.getCoordinatesY()[i]);
			}
		}
		
		return pAux;
	}
	public Esquina getEsquinaRandom ()
	{
		this.esquinaRandom = MathUtils.random(0, this.path.getSize() - 1);
		return new Esquina (this.esquinaRandom,this.path.getCoordinatesX()[this.esquinaRandom],this.path.getCoordinatesY()[this.esquinaRandom]);
	}
	public Esquina getEsquina(int pIndex)
	{
		return new Esquina (pIndex,this.path.getCoordinatesX()[pIndex],this.path.getCoordinatesY()[pIndex]);
	}
	
	
	public class Esquina {
		
		public int index;
		public float x;
		public float y;
		
		public Esquina(int pIndex, float pX, float pY)
		{
			this.index = pIndex;
			this.x = pX;
			this.y = pY;
		}
		
	}
	
}
